#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main() {
    char arr[80000];
    scanf("%s", arr);
    unsigned int sum = 0;
    for (char* p = arr; *p; p++) {
        if (*p == 'C')
            for (char* a = p + 1; *a; a++)
                if (*a == 'H')
                    for (char* b = a + 1; *b; b++)
                        if (*b == 'N')
                            sum++;
    }
    printf("%u", sum);
    return 0;
}